package top.tangyh.lamp.care.controller;

import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import top.tangyh.basic.exception.code.ExceptionCode;
import top.tangyh.basic.interfaces.echo.EchoService;
import top.tangyh.basic.base.controller.SuperController;
import top.tangyh.basic.utils.DateUtils;
import top.tangyh.lamp.care.service.BPgRecordDetailService;
import top.tangyh.lamp.care.entity.BPgRecordDetail;
import top.tangyh.lamp.care.vo.save.BCarePgVteSaveVO;
import top.tangyh.lamp.care.vo.save.BPgRecordDetailSaveVO;
import top.tangyh.lamp.care.vo.update.BPgRecordDetailUpdateVO;
import top.tangyh.lamp.care.vo.result.BPgRecordDetailResultVO;
import top.tangyh.lamp.care.vo.query.BPgRecordDetailPageQuery;

import javax.validation.Valid;
import java.util.ArrayList;
import java.util.List;
import top.tangyh.basic.base.R;
import top.tangyh.lamp.system.service.application.DefApplicationService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
/**
 * <p>
 * 前端控制器
 * 评估评分明细
 * </p>
 *
 * @author zqb
 * @date 2024-07-08 16:40:03
 * @create [2024-07-08 16:40:03] [zqb]
 */
@Slf4j
@RequiredArgsConstructor
@Validated
@RestController
@RequestMapping("/PgRecorDetail")
@Tag(name = "评估评分-明细")
public class BPgRecordDetailController {
//    extends SuperController<BPgRecordDetailService, Long, BPgRecordDetail
//            , BPgRecordDetailSaveVO, BPgRecordDetailUpdateVO, BPgRecordDetailPageQuery, BPgRecordDetailResultVO>
//    private final EchoService echoService;
//    @Override
//    public EchoService getEchoService() {
//        return echoService;
//    }


    private final BPgRecordDetailService bPgRecordDetailService;



//
//    @Operation(summary ="新增入院评估")
//    @PostMapping("/add")
//    public R add(@RequestBody YxCarePgRecordVO carePgRecordVo) {
//
//        if(yxPgRecordTemporaryService.check(carePgRecordVo.getHospitalNumber(),carePgRecordVo.getType()) == false){
//            return R.error(SysCodeEnum.PERMISSION_DENIED);
//        }
//
//        carePgRecordVo.setPfTime(DateUtils.getDateTimeOfTimestamp(carePgRecordVo.getPftimeLong()));
//        YxCarePgRecordPO po = ConvertUtil.convert(carePgRecordVo, YxCarePgRecordPO.class);
//        yxCarePgRecordService.checkPg(po);
//
//        boolean result = yxCarePgRecordService.save(po);
//        if(result){
//            yxPgRecordTemporaryService.cleanPgRedis(carePgRecordVo.getHospitalNumber(),carePgRecordVo.getType());
//            return R.success();
//        }
//        else{
//            return R.error();
//        }
//    }
//
//    @Operation(summary ="更新入院评估")
//    @PutMapping("update/carePgRecord")
//    public R updateById(@ApiParam("入院评估对象") @Valid @RequestBody YxCarePgRecordVO carePgRecordVo) {
//
//        if(yxPgRecordTemporaryService.check(carePgRecordVo.getHospitalNumber(),carePgRecordVo.getType()) == false){
//            return R.error(SysCodeEnum.PERMISSION_DENIED);
//        }
//
//        YxCarePgRecordPO po = ConvertUtil.convert(carePgRecordVo, YxCarePgRecordPO.class);
//        if(null != po.getId()){
//            YxCarePgRecordPO old = yxCarePgRecordService.getById(po.getId());
//            if(null != SecurityUtil.checkRecordAuth(old.getCreateBy() ,old.getUpdateBy())){
//                throw new BadRequestException(SecurityUtil.checkRecordAuth(old.getCreateBy() ,old.getUpdateBy()));
//            }
//        }
//        boolean result = yxCarePgRecordService.updateById(po);
//        if (result) {
//            yxPgRecordTemporaryService.cleanPgRedis(carePgRecordVo.getHospitalNumber(),carePgRecordVo.getType());
//            return R.success();
//        } else {
//            return R.error();
//        }
//    }

//    @Operation(summary ="根据ID查询入院评估详情")
//    @GetMapping(value = "/carePgRecord/{id}")
//    public R<YxCarePgRecordPO> getCarePgRecord(@PathVariable("id") Long id) {
//        YxCarePgRecordPO po=yxCarePgRecordService.getById(id);
//        po.setPftimeLong(DateUtils.getTimestampOfDateTime(po.getPfTime()));
//        return R.success(po);
//    }
//
//    /**
//     * 查询护理入科评估列表 按照type分组
//     */
//    @GetMapping(value = "/list")
//    @Operation(summary =value = "查询护理入科评估列表-按照type分组")
//    public R<List<YxCarePgRecordTypeVO>> list(@ApiParam(value = "病人识别号" , required=true ) @RequestParam String patientIdent,
//                                                 @ApiParam(value = "类型") @RequestParam(required = false) Integer type,
//                                                 @ApiParam(value = "入科时间") @RequestParam(required = false) Long rkTime,
//                                                 @ApiParam(value = "出科时间") @RequestParam(required = false) Long ckTime) {
//        List<YxCarePgRecordTypeVO> list_result = new ArrayList<>();
//        List<YxCarePgRecordPO> list = yxCarePgRecordService.listByPatientIdent(patientIdent,type,rkTime,ckTime);
//        for (int i = 0; i < list.size(); i++) {
//            YxCarePgRecordTypeVO vo = new YxCarePgRecordTypeVO();
//            vo.setPo(list.get(i));
//            vo.setType(list.get(i).getType());
//            list_result.add(vo);
//        }
//        return R.success(list_result);
//    }
//
//    @DeleteMapping
//    @Operation(summary ="删除")
//    public R<Boolean> delete(@RequestParam Integer id) {
//        if(null != id){
//            YxCarePgRecordPO old = yxCarePgRecordService.getById(id);
//            if(null != SecurityUtil.checkRecordAuth(old.getCreateBy() ,old.getUpdateBy())){
//                throw new BadRequestException(SecurityUtil.checkRecordAuth(old.getCreateBy() ,old.getUpdateBy()));
//            }
//
//        }
//
//        if(yxPgRecordTemporaryService.checkDeleteById(id) == false){
//            return R.error(false);
//        }
//        return R.success(yxCarePgRecordService.removeById(id));
//    }

}


